#pragma once

/*
* The following is the definition of the state structure
* used by the G.721/G.723 encoder and decoder to preserve their internal
* state between successive calls.  The meanings of the majority
* of the state structure fields are explained in detail in the
* CCITT Recommendation G.721.  The field names are essentially indentical
* to variable names in the bit level description of the coding algorithm
* included in this Recommendation.
*/
struct g72x_state {
	int yl;	/* Locked or steady state step size multiplier. */
	short yu;	/* Unlocked or non-steady state step size multiplier. */
	short dms;	/* Short term energy estimate. */
	short dml;	/* Long term energy estimate. */
	short ap;	/* Linear weighting coefficient of 'yl' and 'yu'. */

	short a[2];	/* Coefficients of pole portion of prediction filter. */
	short b[6];	/* Coefficients of zero portion of prediction filter. */
	short pk[2];	/*
					* Signs of previous two samples of a partially
					* reconstructed signal.
					*/
	short dq[6];	/*
					* Previous 6 samples of the quantized difference
					* signal represented in an internal floating point
					* format.
					*/
	short sr[2];	/*
					* Previous 2 samples of the quantized difference
					* signal represented in an internal floating point
					* format.
					*/
	char td;	/* delayed tone detect, new in 1988 version */
};

class G721Codec
{
public:
	G721Codec(void);
	~G721Codec(void);

public:
	int  Initialzie();
	void EncodeG721(unsigned char * dst , short * src , unsigned count);
	void DecodeG721(short * dst , unsigned char * src , unsigned count);

public:
	bool m_bInit;

private:
	g72x_state  m_xG72x;
	g72x_state *state_ptr;

};
